const fs = require("fs");
const path = require("path");
const fullPath = path.resolve(__dirname, "./data.txt");

function call(err) {
  if (err) {
    console.log("error -", err);
    return;
  }
  console.log("success");
}

const opt = {
  flag: "a", // 追加写入，覆盖 w
};

/**
 * file文件名
 * data写入数据
 * options配置
 * callback回调
 */
// 异步写入
fs.writeFile(fullPath, "异步写入\n", opt, call);
